<div class="tmd-doc">
<p></p>
<h1 class="tmd-header-1">
const 3
</h1>
<p></p>
<div id="question" class="tmd-base">
<div class="tmd-usual">
What does the following program print (if it runs on a 64-bit OS)?
</div>
<p></p>
<pre class="tmd-code line-numbers">
<code class="language-go">package main

const X = '\x61' // 'a'
const Y = 0x62
const A = Y - X // 1
const B int64 = 1

var n = 32

func main() {
	if A == B {
		println(A &lt;&lt; n &gt;&gt; n, B &lt;&lt; n &gt;&gt; n)
	}
}
</code></pre>
</div>
<p></p>
<div class="tmd-usual">
Choices:
</div>
<p></p>
<input type="radio" id="choiceA" name="choice" class="choice">
<input type="radio" id="choiceB" name="choice" class="choice">
<input type="radio" id="choiceC" name="choice" class="choice">
<input type="radio" id="choiceD" name="choice" class="choice">

<div id="choices">

<ul style="list-style-type:none;">
<li><label for="choiceA">0 0</label></li>
<li><label for="choiceB">0 1</label></li>
<li><label for="choiceC">1 1</label></li>
<li><label for="choiceD">(It prints nothing)</label></li>
</ul>

</div><p></p>
<div id="answer" class="tmd-base">
<div class="tmd-usual">
Answer: 0 1
</div>
<p></p>
<div class="tmd-usual">
Run it on <a href="https://go.dev/play/p/3cRh94zYsHV">Go play</a>.
</div>
<p></p>
<div class="tmd-usual">
Key points:
</div>
<ul class="tmd-list">
<li class="tmd-list-item">
<div class="tmd-usual">
Untyped <code class="tmd-code-span">X</code> is a rune constant (in other words, its default type is <code class="tmd-code-span">rune</code>, a.k.a <code class="tmd-code-span">int32</code>, a 32-bit integer type). Untyped <code class="tmd-code-span">Y</code> is an int constant (in other words, its default type is <code class="tmd-code-span">int</code>, a 64-bit integer type on 64-bit OSes).
</div>
</li>
<li class="tmd-list-item">
<div class="tmd-usual">
At run time, the expression <code class="tmd-code-span">A &lt;&lt; n</code> overflows, so it is evaluated as 0; on the other hand, the expression <code class="tmd-code-span">B &lt;&lt; n</code> doesn't overflow.
</div>
</li>
</ul>
<p></p>
</div>
<p></p>
</div>
